package com.noble.meether.ui.invite.detail.panel;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.noble.meether.R;
import com.noble.glamour.module.logic.baseui.ExBaseAdapter;
import com.noble.library.image.ImageLoader;
import com.noble.meether.ui.invite.detail.bean.InviteDetail;

import java.util.List;

/**
 * Created by Su on 2018/6/14.
 */
public class InviteDetailAdapter extends ExBaseAdapter<InviteDetail> {

    public InviteDetailAdapter(Context context, List<InviteDetail> data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder holder;
        if (convertView == null) {
            convertView = inflate(R.layout.item_invite_detail);
            holder = new MyViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (MyViewHolder) convertView.getTag();
        }
        final InviteDetail info = getItem(position);
        ImageLoader.loadCircleAvatar(getContext(), info.getAvatarSon(), holder.item_avatar);
        holder.item_name.setText(info.getNickNameSon());
        holder.item_time.setText(info.getTimeReg());
        return convertView;
    }

    private class MyViewHolder {
        private ImageView item_avatar;
        private TextView item_name, item_time;

        public MyViewHolder(View convertView) {
            initView(convertView);
        }

        private void initView(View convertView) {
            item_avatar = convertView.findViewById(R.id.item_avatar);
            item_name = convertView.findViewById(R.id.item_name);
            item_time = convertView.findViewById(R.id.item_time);
        }
    }
}
